{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "26fa4b34",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.datasets import load_iris\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.naive_bayes import MultinomialNB, GaussianNB\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn.metrics import confusion_matrix as CM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "d42cab41",
   "metadata": {},
   "outputs": [],
   "source": [
    "iris_dataset = load_iris()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "f003302b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9333333333333333\n",
      "[[38  2  0]\n",
      " [ 0 33  4]\n",
      " [ 0  2 41]]\n"
     ]
    }
   ],
   "source": [
    "iris_x = iris_dataset.data\n",
    "iris_y = iris_dataset.target\n",
    "\n",
    "x_train, x_test, y_train, y_test = train_test_split(iris_x, iris_y, test_size=0.8, random_state=1)\n",
    "\n",
    "clf = Pipeline([\n",
    "         ('sc', StandardScaler()),\n",
    "         ('clf', GaussianNB())])     \n",
    "ir = clf.fit(x_train, y_train.ravel())  \n",
    " \n",
    " \n",
    "y_predict = ir.predict(x_test)\n",
    "y_score = ir.score(x_test, y_test)\n",
    "\n",
    "print(y_score)\n",
    "print(CM(y_test, y_predict))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "da1cd641",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9333333333333333\n",
      "[[38  2  0]\n",
      " [ 0 33  4]\n",
      " [ 0  2 41]]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.datasets import load_iris\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.naive_bayes import MultinomialNB, GaussianNB\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn.metrics import confusion_matrix as CM\n",
    "\n",
    "iris_dataset = load_iris()\n",
    "\n",
    "iris_x = iris_dataset.data\n",
    "iris_y = iris_dataset.target\n",
    "\n",
    "x_train, x_test, y_train, y_test = train_test_split(iris_x, iris_y, test_size=0.8, random_state=1)\n",
    "\n",
    "clf = Pipeline([\n",
    "         ('sc', StandardScaler()),\n",
    "         ('clf', GaussianNB())])     \n",
    "ir = clf.fit(x_train, y_train.ravel())  \n",
    " \n",
    " \n",
    "y_predict = ir.predict(x_test)\n",
    "y_score = ir.score(x_test, y_test)\n",
    "\n",
    "print(y_score)\n",
    "print(CM(y_test, y_predict))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ecca4b28",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
